<template>
  <div>
    首页{{ name }}

    <span @click="sendMessage">send</span>
  </div>
</template>

<script setup lang='ts'>
const name = ref<string>("zheshi");

import { io } from "socket.io-client";

const socket = io("http://localhost:9678");
/**
 *  {
  transports: ["websocket"], // 指定传输方式，如WebSocket
  autoConnect: true, // 是否自动连接
  reconnection: true, // 是否自动重新连接
  reconnectionAttempts: 3, // 重新连接尝试次数
  reconnectionDelay: 1000, // 重新连接延迟时间（毫秒）
  query: { token: "your-token" }, // 自定义查询参数
  // 其他可选参数...
}
 * 
 */
const sendMessage = () => {
  socket.emit("join", { roomId: "123", name: "查询参数" });
};
// socket.on("join", (e) => {
//   console.log(e);
// });
</script>

<style lang='scss' scoped>
span {
  cursor: pointer;
}
</style>
